//
//  UILabel+AutoHeight.m
//  记账本
//
//  Created by mac on 16/3/1.
//  Copyright © 2016年 Simon. All rights reserved.
//

#import "UILabel+AutoHeight.h"

@implementation UILabel (AutoHeight)

+ (CGFloat)heightWithText:(NSString *)text withFontSize:(CGFloat)fontSize withWidth:(CGFloat)width {
    
    NSDictionary *attributes = @{
                                 NSFontAttributeName : [UIFont systemFontOfSize:fontSize]
                                 
                                 };
    
    CGRect rect = [text boundingRectWithSize:CGSizeMake(width, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin attributes:attributes context:nil];
    
    CGFloat height = rect.size.height;
    
    return height;
}

@end
